import { useEffect, useState } from "react";
import axios from "axios";
//相对路径拿到json数据位置
function Related() {
  //获取数据
  const [data, setData] = useState([]);

  useEffect(() => {
    axios
      .get("src/components/data/sticky.json")
      .then((response) => {
        setData(response.data.data);
        console.log(response.data);
      })
      .catch((error) => console.log(error));
  }, []);

  return (
    <>
      {data.map((item, index) => (
        <a key={index} href="#" target="_blank" className="bullet-item">
          <div className="info">
            <span className="title text_ellipsis2">{item.title}</span>
            <span className="vol">VOL.{item.number}</span>
          </div>
          <img src={item.cover} className="cover" />
        </a>
      ))}
    </>
  );
}
